﻿ <%@ Page Title="" Language="C#" MasterPageFile="~/Admin/BaseMaster/Pages.Master" AutoEventWireup="true" CodeBehind="UpdateUserPwd.aspx.cs" Inherits="Liu_Project.Web.Admin.Pages.Personal.EntUser.UpdateUserPwd1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="baseTitle" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="baseHead" runat="server">
    <style>
        .layui-form-item .layui-input-inline {width:388px !important;}
    </style>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="baseContent" runat="server">
    <div class="layui-row layui-col-space10">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">修改密码</div>
                <div class="layui-card-body">
                    <form class="layui-form" lay-filter="userForm" id="userForm" style="padding: 20px;">
                        <div class="layui-form-item">
                            <label class="layui-form-label">当前密码</label>
                            <div class="layui-input-inline">
                                <input type="password" name="OldPwd" placeholder="请输入当前密码" lay-verify="required|pass" lay-vertype="tips" autocomplete="new-password" class="layui-input" maxlength="12">
                            </div>
                            <div class="layui-form-mid layui-word-aux pwd"></div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">新密码</label>
                            <div class="layui-input-inline">
                                <input type="password" name="Password" placeholder="请输入新密码" lay-verify="required|pass" lay-vertype="tips" autocomplete="new-password" class="layui-input" maxlength="12">
                            </div>
                            <div class="layui-form-mid layui-word-aux pwd">密码必须6到12位，且不能出现空格</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">确认密码</label>
                            <div class="layui-input-inline">
                                <input type="password" id="newPwd" placeholder="请输入确认新密码" lay-verify="required|newpass" lay-vertype="tips" autocomplete="new-password" class="layui-input" maxlength="12">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button type="submit" class="layui-btn" lay-submit lay-filter="*">确认修改</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="baseScript" runat="server">
    <script>
        !function () {
            var CurrData = {};
            
            QueryById();
            function QueryById() {
                GetObjectInfoFunction_Async("Admin/Handler/BaseHand/UserRoleHand.ashx", { "act": "QueryById" }, function (result) {
                    if (result.IsSuccess) {
                        if (result.data.length == 0)
                            return;
                        CurrData = result.data;
                    }
                })
            }

            layui.form.verify({
                pass: function (value, item) {
                    if (value.length == 0)
                        return;
                    if (!new RegExp(/^[\S]{6,12}$/).test(value)) {
                        return '密码必须6到12位，且不能出现空格';
                    }
                }, newpass: function (value) {
                    var pvalue = $("input[name='Password']").val();
                    if (pvalue.length == 0)
                        return;
                    if (!(value.length >= 6) || value.length > 12) {
                        return "密码必须6到12位";
                    }
                    if (pvalue != value) {
                        return "两次输入的密码不相同";
                    };
                }
            });

            layui.form.on('submit(*)', function (data) {
                UpdateJson(CurrData, data.field)
                top.layer.load(1);
                GetObjectInfoFunction_Async("Admin/Handler/BaseHand/UserRoleHand.ashx", {
                    "act": "Save", "_state": "Edit", "OldPwd": CurrData.OldPwd, "Data": JSON.stringify(CurrData)
                }, function (result) {
                    $("#userForm")[0].reset();
                    QueryById();
                    top.layer.msg('保存成功');
                })

                return false;
            });
        }();
    </script>
</asp:Content>
